<template>
	<view class="content">
		
	<!-- <mescroll-uni @down="downCallback" @up="upCallback" > -->
		<view class="list-container"  v-for="(item,index) in list" :key="index" >
			<view class="shenhe-list1" @tap="goinfo" :data-id="item.id">
				<view class="clear shenhe-text" >
					<text class="left">客户姓名 </text>
					<text class="right blue_text" style="font-weight: bold;">{{item.nickname}}</text>
				</view>
				<view class="clear shenhe-text" >
					<text class="left">销售经理 </text>
					<text class="right ">{{item.manage_name}}</text>
				</view>
				<view class="clear shenhe-text" >
					<text class="left">申请时间 </text>
					<text class="right">{{item.time}}</text>
				</view>
				<image src="../../static/img/to.png" class="go_icon"></image>
			</view>	
		</view>
	<!-- </mescroll-uni> -->
		<image src="../../static/img/nodata.png" class="no-data" v-if="ishas1"  mode="widthFix"></image>	
		
	</view>
</template>

<script>
	import httpPath from '@/static/js/path.js';
	import {getlogin} from '@/static/js/login.js';
	import {fmoney} from '@/static/js/login.js';
	import {timestampToDate} from '@/static/js/login.js';
	import MescrollUni from "@/components/mescroll-uni/uni-load-more.vue";	
	var  _self,
	page = 1;
	export default {
		data() {
			return {
				type: 0,
				list:[],
				name: '',
				user:{},
				ishas1:false,
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				}
			};
		},
		components: {
			MescrollUni
		},
		// components: {uniLoadMore},
		onLoad(e) {
			this.user = getlogin();
			if(!this.user.islogin){
				uni.showModal({
				   showCancel:false,
				   content:"您还没有登录，请登录"
				})
				uni.navigateTo({
					url:"../public/login"
				})
			}	
			page = 1;
			_self = this;
			// _self.type = e.id;
			_self.fnGetData();
		},
		onShow() {
			this.user = getlogin();
			if(!this.user.islogin){
				uni.showModal({
				   showCancel:false,
				   content:"您还没有登录，请登录"
				})
				uni.navigateTo({
					url:"../public/login"
				})
			}	
			page = 1;
			_self.fnGetData();
		},
		onReachBottom: function() {
			if (_self.loadingType != 0) {//loadingType!=0;直接返回
				return false;
			}
			_self.loadingType = 1;
			uni.showNavigationBarLoading();//显示加载动画
			page++;//每触底一次 page +1
			uni.request({
				url: httpPath.filePath+"/api.php/index/user/customer_check_list",
				method:'POST',
				header:{'content-type':'application/x-www-form-urlencoded'},
				data: {page:page,member_id:this.user.member_id,user_id:this.user.user_id},
				success: (res) => {
					if (res.data.result.length==0) {//没有数据
						_self.loadingType = 2;
						uni.hideNavigationBarLoading();//关闭加载动画
						return false;
					}
					
					for (let i = 0;i < res.data.result.length;i++) {
						res.data.result[i].time = timestampToDate(res.data.result[i].addtime)
						_self.list.push(res.data.result[i]);
						
						// _self.list[i].time= _self.timestampToDate(res.data.result[i].addtime)
											// }
					}
					_self.loadingType = 0;//将loadingType归0重置
					uni.hideNavigationBarLoading();//关闭加载动画
				}
			});
		},
		onPullDownRefresh() {
			page=1
			_self.loadingType=0;
		    this.fnGetData();   
		    setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
		goaddkehu(id){
			uni.navigateTo({
				url:"editkehu"
			})
		},
		goinfo(e){
			uni.navigateTo({
				url:"ziliaoinfo?id="+e.currentTarget.dataset.id
			})
		},
			fnGetData(){

				uni.request({
					url: httpPath.filePath+"/api.php/index/user/customer_check_list",
					method: 'POST',
					data:  {page:page,member_id:this.user.member_id,user_id:this.user.user_id},
					header:{'content-type':'application/x-www-form-urlencoded'},
					success: res => {
						if(res.data.code == "200"){
							this.list = res.data.result;
							if(this.list.length==0){
								this.ishas1=true;
							}else{
								this.ishas1=false;
							}
							for(let i=0;i<this.list.length;i++){
								this.list[i].time= timestampToDate(res.data.result[i].addtime)
							}
						}
					}
				});
			},
		},
		
	}
</script>

<style>
	@import "../../colorui/main.css";
	page{background: #FFFFFF;}
</style>
